﻿Public Class 组件表操作类

    Public Shared Function Insert(ByVal 组件 As 组件表) As Boolean
        Dim sb As New System.Text.StringBuilder
        sb.AppendLine(" Insert into ")

        sb.AppendLine("组件(")
        sb.AppendLine(" 组件名称")
        sb.AppendLine(",组件路径")
        sb.AppendLine(",顺序")
        sb.AppendLine(",表")

        sb.AppendLine(",添加表")
        sb.AppendLine(",修改表")
        sb.AppendLine(",删除表")
        sb.AppendLine(",触发器")
        sb.AppendLine(",添加触发器")

        sb.AppendLine(",修改触发器")
        sb.AppendLine(",删除触发器")
        sb.AppendLine(",界面")
        sb.AppendLine(",菜单")
        sb.AppendLine(",工具栏")

        sb.AppendLine(",数据浏览窗体")
        sb.AppendLine(",不使用")
        sb.AppendLine(") Values(")

        sb.AppendLine(" '" & 组件.组件名称 & "'")
        sb.AppendLine(" ,''")
        sb.AppendLine(" ," & 组件.顺序 & "")
        sb.AppendLine(" ," & 组件.表 & "")

        sb.AppendLine(" ," & 组件.添加表 & "")
        sb.AppendLine(" ," & 组件.修改表 & "")
        sb.AppendLine(" ," & 组件.删除表 & "")
        sb.AppendLine(" ," & 组件.触发器 & "")
        sb.AppendLine(" ," & 组件.添加触发器 & "")

        sb.AppendLine(", " & 组件.修改触发器 & "")
        sb.AppendLine(" ," & 组件.删除触发器 & "")
        sb.AppendLine(" ," & 组件.界面 & "")
        sb.AppendLine(" ," & 组件.菜单 & "")
        sb.AppendLine(" ," & 组件.工具栏 & "")

        sb.AppendLine(" ," & 组件.浏览数据窗体 & "")
        sb.AppendLine(" ," & 组件.不使用 & "")
        sb.AppendLine(" )")

        Return DBUtil.ExectueSql(sb.ToString)

    End Function

    Public Shared Function Update(ByVal 组件 As 组件表) As Boolean

        Delete(组件)

        Insert(组件)

        Return True

    End Function

    Public Shared Function Delete(ByVal 组件 As 组件表) As Boolean

        Dim strsql As String = "delete from 组件 where 组件名称='" + 组件.组件名称 + "'"

        Return DBUtil.ExectueSql(strsql)

    End Function

    Public Shared Function GetAll组件(Optional ByVal type As Integer = 0) As List(Of 组件表)

        Dim lst As New List(Of 组件表)

        Dim dt As DataTable = DBUtil.组件配置表

        For index As Integer = 0 To dt.Rows.Count - 1

            Dim 组件 As New 组件表

            组件.组件名称 = dt.Rows(index)("组件名称")
            '组件.组件路径 = dt.Rows(index)("组件路径")
            组件.顺序 = dt.Rows(index)("顺序")
            组件.表 = dt.Rows(index)("表")
            组件.添加表 = dt.Rows(index)("添加表")
            组件.修改表 = dt.Rows(index)("修改表")

            组件.删除表 = dt.Rows(index)("删除表")
            组件.触发器 = dt.Rows(index)("触发器")
            组件.添加触发器 = dt.Rows(index)("添加触发器")
            组件.修改触发器 = dt.Rows(index)("修改触发器")
            组件.删除触发器 = dt.Rows(index)("删除触发器")

            组件.界面 = dt.Rows(index)("界面")
            组件.菜单 = dt.Rows(index)("菜单")
            组件.工具栏 = dt.Rows(index)("工具栏")
            组件.浏览数据窗体 = dt.Rows(index)("数据浏览窗体")
            组件.不使用 = dt.Rows(index)("不使用")

            If type = 0 Then
                If 组件.不使用 = 1 Then
                    Continue For
                End If
            End If
            lst.Add(组件)
        Next

        Return lst

    End Function


    Public Function Get组件(ByVal 组件 As 组件表) As 组件表

        Dim lst As New 组件表

        Return lst

    End Function

End Class
